package com.filetransfer.filesTCP.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Description: these message can be deleted
 * Author:sold out
 * Create Date: 2021/12/20 23:44
 * Version: JDK 1.8
 */
public class ObjectMapperUtil {

    private static ObjectMapper objectMapper;

    public static ObjectMapper getObjectMapper() {
        if (objectMapper != null) {
            objectMapper = new ObjectMapper();
        }
        return objectMapper;
    }

    public static String handleObjectToString(Object obj) {
        try {
            return objectMapper.writeValueAsString(obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "\"status\" : \"失败\"";
    }

}
